<?php
namespace Lib\Encryption;
/**
 * Enter description here ...
 * 
 * @author diotheos
 * @package Encryption
 */
class DriverFactory{
    private function __construct($options = array()){}
    private function __clone(){}
    
    const ENCRYPTION_DRIVER_MCRYPT = 'Driver\Mcrypt';
    
    /**
     * Creates instance of encryption driver
     * 
     * @param int $driverName
     * @throws EncryptionException
     */
    public static function factory($driverName = self::ENCRYPTION_DRIVER_MCRYPT, $driverOptions = array()){
        switch ($driverName){
            case self::ENCRYPTION_DRIVER_MCRYPT:
                $driverName = __NAMESPACE__ . '\\' . $driverName;
                $driver = new $driverName();
            break;
            
            default:
                throw new EncryptionException('Encryption driver not founded: '.$driverName);
        }
        $driver->setOptions($driverOptions);
        return $driver;
    }
}